Skip to content

Enable linting rules for S110: try-except-pass#495

Merged
brianhelba merged 1 commit intomainfrom
lint-except-pass
Apr 30, 2026
Merged

Enable linting rules for S110: try-except-pass#495
brianhelba merged 1 commit intomainfrom
lint-except-pass

Conversation

@brianhelba
Copy link
Copy Markdown
Member

No description provided.


if mode == "multi-otsu":
try:
with contextlib.suppress(ValueError):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this uses a more specific exception, that seems likely to actually be raised by threshold_multiotsu.


if mode == "multi-otsu":
try:
with contextlib.suppress(ValueError):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BryonLewis Can you verify that the correct behavior on an exception is indeed to silently proceed to the end of the function and call np.percentile instead?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test it tomorrow. There may be an argument for removing this whole contour extraction from the application. We were using it before to generate contours from spectrogram images for clearer delineation between values, but without some decent filtering (reduction in contour accuracy) and not knowing the size of the wav files, the loading times and data size could be too large to be generally useful.

We have disabled this section of the conversion process from wav to spectrogram + metadata.

Copy link
Copy Markdown
Member Author

@brianhelba brianhelba Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. That is indeed what the code did and still does. I just wondered if it was overly eager to suppress exceptions that should actually be allowed to cause a failure.

@brianhelba brianhelba requested a review from BryonLewis April 22, 2026 20:19
Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine to merge in to at least remove the suppressed lint rule. If we end up renabling the contour generation I could run a couple hundred files through it and check any other errors that may be created.

For Reference:
While the contour generation was part of the conversion it wasn't necessary for the annotation process and was a 'nice-to-have'. If contour generation failed it just wouldn't provide the contours in the user interface for the annotator. We have since disabled the contours because they were too heavy and not of much use.

@brianhelba brianhelba merged commit a589c8e into main Apr 30, 2026
3 checks passed
@brianhelba brianhelba deleted the lint-except-pass branch April 30, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants